﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;

namespace AudioEffectBox
{
    public class Audio16StereoBalancerStream : Audio16ModulationStream
    {
        public Audio16StereoBalancerStream(Stream secondaryInput, int modulationLevel, Stream outputStream, int modulationSpeed):
            base(secondaryInput,modulationLevel,outputStream,modulationSpeed)
        {

        }
        protected override void ProcessSample(Int16 sample)
        {
            Int16 leftSample = sample;
            Int16 rightSample = sample;
            if (IsEnabled)
            {
                leftSample = (Int16)((sample * _lastModulationSample) / ModulationLevel);
                rightSample = (Int16)((sample * (ModulationLevel - _lastModulationSample)) / ModulationLevel);
            }
            _writer.Write(leftSample);
            _writer.Write(rightSample);
        }
    }
}
